<?php
include("../include/config.inc.php");
include("userlogincheck.php");

$sql="select * from ".tableprefix."store where store_state='1' and member_id=$userid";
$result=$db->query($sql);
$row=$db->fetch_array($result);
$db->free_result($result);
$grade_id=$row["grade_id"];
if($grade_id=='2'){
$temp_store_credit='诚信商户';
}elseif($grade_id=='3'){
$temp_store_credit='特约商户';
}else{
$temp_store_credit='普通商户';
}

$sql = "select count(*) as count from ".tableprefix."cashout where flag='T' and cashtype='保证金' and status='0' and userid='$userid'";
$rs=$db->fetch_array($db->query($sql));
$count=$rs["count"];//记录总数
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>保证金 - 订戏会</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=9,Chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="stylesheet" type="text/css" href="../css/public.css">
<link rel="stylesheet" type="text/css" href="../css/user.css">
<script type="text/javascript" src="../js/clientwidth.js"></script>
<script language="javascript">
    function confirmdel(id,page){
       if (confirm("保证金将在1-3个工作日内审核完成原路返回，确定要退保证金吗？"))
       window.location.href="bondback.php?id="+id+"&page="+page
     }  
</script>
</head>

<body>
<section class="container">
	<div class="personal-head">
    	<img alt="商家LOGO" src="<?php if($row["store_label"]==''){echo "../images/storenav_01.jpg";}else{echo "../".$row['store_label'];}?>">
        <div class="p-head-info">
        	<p class="p-nickname"><?php echo $row["store_name"];?></p>
        	<p class="p-platform"><?php echo $row["store_phone"];?><span><?php echo $temp_store_credit;?></span></p>
        </div>
	</div>        
</section>
<div class="bondwarp">
	<div class="bond_icon"><img src="../images/baozhengjin.jpg"></div>
	<div class="bond_text">保证金金额</div>
	<div class="bond_price">￥<?php echo number_format($row["store_credit"],2);?>元</div>
</div>
<?php
if($row["grade_id"]==0){
?>
<?php
if($count==1){
?>
<div class="paybtn"><div class="paybox">退保申请中</div></div>
<?php
}else{
?>
<div class="paybtn"><a href="../publish/store-grade.php"><div class="paybox">提交保证金</div></a></div>
<?php
}
?>
<?php
}else{
?>
<div class="paybtn"><a href='javascript:confirmdel("<?php echo $row["store_id"]?>")'><div class="paybox">退保证金</div></a></div>
<?php
}
?>
<div class="back"><a href="mywallet.php"><div class="backup">返回</div></a></div>

<div id="bottom"></div>

<footer id="bar-fixed">
	<a href="../" class="tab-item"><i class="icon-tabbar bar-home"></i>首页</a>
	<a href="../category.php" class="tab-item"><i class="icon-tabbar bar-message"></i>分类</a>
	<a href="../publish/" class="tab-item"><i class="icon-tabbar bar-publish"></i>发布</a>	
	<a href="../user/" class="tab-item active"><i class="icon-tabbar bar-user2"></i>我</a>
</footer>
<script>
if (document.body.clientWidth > 640) {
	$('body').css({
		width: 640,
		margin: '0 auto',
	});
}
</script>
</body>
</html>
<?php
$db->close();
exit;
?>